home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / effects / qtshoweffect / qtshoweffect.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  6.2 KB  |  207 lines

  1. //////////
  2. //
  3. //    File:        QTShowEffect.h
  4. //
  5. //    Contains:    Code to generate a QuickTime movie with a QuickTime video effect in it,
  6. //                and to preview an effect on zero, one, or two pictures.
  7. //
  8. //    Written by:    Tim Monroe
  9. //                Based on existing ShowEffect code written by Dan Crow,
  10. //                which was adapted from Peter Hoddie's original DoEffect code.
  11. //
  12. //    Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  13. //
  14. //    Change History (most recent first):
  15. //
  16. //       <1>         12/15/97    rtm        first file; integrated existing code with shell framework
  17. //       
  18. //////////
  19.  
  20.  
  21. //////////
  22. //
  23. // header files
  24. //
  25. //////////
  26.  
  27. #include "ComApplication.h"
  28. #include <Controls.h>
  29. #include <Devices.h>
  30. #include <Dialogs.h>
  31. #include <DiskInit.h>
  32. #include <FileTypesAndCreators.h>
  33. #include <FixMath.h>
  34. #include <Fonts.h>
  35. #include <ImageCodec.h>
  36. #include <ImageCompression.h>
  37. #include <Movies.h>
  38. #include <QuickTimeComponents.h>
  39. #include <Resources.h>
  40. #include <Sound.h>
  41. #include <stdio.h>
  42. #include <string.h>
  43. #include <TextUtils.h>
  44. #include <ToolUtils.h>
  45.  
  46. #if TARGET_OS_MAC
  47. #include "MacFramework.h"
  48. #endif
  49.  
  50. #if TARGET_OS_WIN32
  51. #include "WinFramework.h"
  52. #endif
  53.  
  54.  
  55. //////////
  56. //
  57. // compiler flags
  58. //
  59. //////////
  60.  
  61. #define USES_MAKE_IMAGE_DESC_FOR_EFFECT    1        // use MakeImageDescriptionForEffect (QT 4.0 and later)
  62. #define ALLOW_COMPOUND_EFFECTS            1        // add a compound effect to the output effects movie?
  63.  
  64.  
  65. //////////
  66. //
  67. // constants
  68. //
  69. //////////
  70.  
  71. // the maximum number of items we'll allow in a pop-up menu
  72. #define kMaxNumPopupMenuItems            75
  73.  
  74. // resource IDs
  75. #define kPreferencesDialogID            131
  76. #define kCustomDialogID                    132
  77. #define kSelectDialogID                    133
  78. #define kSplashDialogID                    134
  79.  
  80. #define kPopUpMenuID                    133
  81.  
  82. #define kWatchCursorResID                128
  83.  
  84. #define kFirstPICTResID                    129
  85. #define kSecondPICTResID                130
  86.  
  87. // dialog item IDs of items in the Select Effect dialog box
  88. #define kSelectButtonOK                    1
  89. #define kSelectPopUpID                    2
  90.  
  91. // dialog item IDs of items in the custom Customize Effect dialog box
  92. #define kCustomPopUpID                    1
  93. #define kCustomStaticTextID                2
  94. #define kCustomButtonOK                    3
  95. #define kCustomUserItemID                4
  96.  
  97. // default width, height, and bit depth of the main window
  98. #define kWidth                            360
  99. #define kHeight                            360
  100. #define kThumbNailWidth                    64
  101. #define kThumbNailHeight                64
  102. #define kDepth                            0
  103.  
  104. // effects sources names
  105. #define kSourceOneName                    FOUR_CHAR_CODE('srcA')
  106. #define kSourceTwoName                    FOUR_CHAR_CODE('srcB')
  107. #define kSourceThreeName                FOUR_CHAR_CODE('srcC')
  108. #define kSourceNoneName                    FOUR_CHAR_CODE('srcZ')
  109.  
  110. // parameters for QTGetEffectsList    
  111. #define kNoMinNumSources                -1
  112. #define kNoMaxNumSources                -1        
  113.  
  114. // looping states
  115. #define kNoLooping                        IDM_NO_LOOPING
  116. #define kNormalLooping                    IDM_NORMAL_LOOPING
  117. #define kPalindromeLooping                IDM_PALINDROME_LOOPING
  118.  
  119. // play directions
  120. #define kForward                        1
  121. #define kBackward                        2
  122.  
  123. // miscellaneous constants
  124. #define kOneSecond                        600
  125. #define kEffectMovieDuration            (5 * kOneSecond)
  126. #define k30StepsCount                    30
  127. #define kWindowOffset                    75
  128.  
  129. #define kSaveEffectMoviePrompt            "Save effect movie file as:"
  130. #define kSaveEffectMovieFileName        "Effect.mov"
  131.  
  132. #define kEffectsWindowClassName            "Effects Window"
  133. #define kEffectsWindowTitle                "Show Video Effect"
  134.  
  135.  
  136. //////////
  137. //
  138. // data types
  139. //
  140. //////////
  141.  
  142. // a structure to hold information about the Select Effect pop-up menu
  143. typedef struct {
  144.     MenuHandle                fMenu;
  145.     short                    fLastChosen;
  146.     short                    fNumberOfItems;
  147.     char                    fMenuText[kMaxNumPopupMenuItems][255];
  148.     OSType                    fItemInfo[kMaxNumPopupMenuItems];
  149. } PopUpMenuInformation;
  150.  
  151. // a structure to hold information about the current effect
  152. typedef struct {
  153.     OSType                    fEffectType;
  154.     ImageDescriptionHandle    fSampleDescription;
  155.     Boolean                    fShowingEffect;
  156.     Boolean                    fSteppingEffect;
  157.     ImageSequence            fEffectSequenceID;
  158.     QTAtomContainer            fEffectDescription;
  159.     TimeBase                fTimeBase;
  160.     TimeValue                fTime;
  161. } StateInformation;
  162.  
  163.  
  164. //////////
  165. //
  166. // function prototypes
  167. //
  168. //////////
  169.  
  170. OSErr                        QTEffects_Init (void);
  171. OSErr                        QTEffects_Stop (void);
  172.  
  173. void                        QTEffects_ProcessEffect (void);
  174. void                        QTEffects_DrawEffectsWindow (void);
  175. #if TARGET_OS_MAC
  176. Boolean                        QTEffects_HandleEffectsWindowEvents (EventRecord *theEvent);
  177. #elif TARGET_OS_WIN32
  178. LRESULT CALLBACK            QTEffects_HandleEffectsWindowMessages (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam);
  179. BOOL                        QTEffects_RegisterEffectsWindowClass (HANDLE hInstance);
  180. #endif
  181.  
  182. OSErr                        QTEffects_LetUserChooseEffect (void);
  183. OSErr                        QTEffects_LetUserCustomizeEffect (QTAtomContainer theEffectDesc);
  184. # if TARGET_OS_WIN32
  185. static void                    QTEffects_EffectsDialogCallback (EventRecord *theEvent, DialogRef theDialog, DialogItemIndex theItemHit);
  186. LRESULT CALLBACK            QTEffects_CustomDialogWndProc (HWND theWnd, UINT theMessage, UINT wParam, LONG lParam);
  187. #endif
  188. Boolean                        QTEffects_HandleEffectsDialogEvents (EventRecord *theEvent, DialogItemIndex theItemHit);
  189.  
  190. OSErr                        QTEffects_InitializePopUpMenu (PopUpMenuInformation *theMenuInfo);
  191. OSErr                        QTEffects_AddItemToPopUpMenu (PopUpMenuInformation *theMenuInfo, char *theItemText, OSType theItemInfo);
  192. OSErr                        QTEffects_AddListOfEffects (void);
  193.  
  194. QTAtomContainer                QTEffects_CreateEffectDescription (OSType theEffectName, OSType theSourceName1, OSType theSourceName2);
  195. OSErr                        QTEffects_AddTrackReferenceToInputMap (QTAtomContainer theInputMap, Track theTrack, Track theSrcTrack, OSType theSrcName);
  196. OSErr                        QTEffects_SetUpEffectSequence (void);
  197. ImageDescriptionHandle        QTEffects_MakeSampleDescription (OSType theEffectType, short theWidth, short theHeight);
  198. OSErr                        QTEffects_RunEffect (TimeValue theTime);
  199.  
  200. OSErr                        QTEffects_GetPictResourceAsGWorld (short theResID, short theWidth, short theHeight, short theDepth, GWorldPtr *theGW);
  201. OSErr                        QTEffects_GetPictureAsGWorld (short theWidth, short theHeight, short theDepth, GWorldPtr *theGW);
  202. OSErr                        QTEffects_AddVideoTrackFromGWorld (Movie *theMovie, GWorldPtr theGW, Track *theSourceTrack, long theStartTime, short theWidth, short theHeight);
  203.  
  204. void                        QTEffects_CreateEffectsMovie (OSType theEffectType, QTAtomContainer theEffectDesc, short theWidth, short theHeight);
  205. void                        QTEffects_NewCreateEffectsMovie (OSType theEffectType, QTAtomContainer theEffectDesc, short theWidth, short theHeight);
  206. void                        QTEffects_AddFilmNoiseToMovie (Movie theMovie, Track theSrcTrack);
  207.